Imports System.IO
Public Class frmRML
    Inherits System.Windows.Forms.Form

#Region " Create And Fill the Data Set "
#End Region   ' rmortega77 yahoo es

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
    Friend WithEvents cmdPrint1 As System.Windows.Forms.Button

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.CrystalReportViewer1 = New CrystalDecisions.Windows.Forms.CrystalReportViewer
        Me.cmdPrint1 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'CrystalReportViewer1
        '
        Me.CrystalReportViewer1.ActiveViewIndex = -1
        Me.CrystalReportViewer1.DisplayGroupTree = False
        Me.CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
        Me.CrystalReportViewer1.Margin = New System.Windows.Forms.Padding(0)
        Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
        Me.CrystalReportViewer1.SelectionFormula = ""
        Me.CrystalReportViewer1.ShowGroupTreeButton = False
        Me.CrystalReportViewer1.ShowPrintButton = False
        Me.CrystalReportViewer1.Size = New System.Drawing.Size(413, 273)
        Me.CrystalReportViewer1.TabIndex = 0
        Me.CrystalReportViewer1.ViewTimeSelectionFormula = ""
        '
        'cmdPrint1
        '
        Me.cmdPrint1.ForeColor = System.Drawing.Color.Red
        Me.cmdPrint1.Location = New System.Drawing.Point(306, 0)
        Me.cmdPrint1.Name = "cmdPrint1"
        Me.cmdPrint1.Size = New System.Drawing.Size(56, 24)
        Me.cmdPrint1.TabIndex = 1
        Me.cmdPrint1.Text = "Print"
        Me.cmdPrint1.UseVisualStyleBackColor = True
        '
        'frmIDBarcode_Input
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(413, 273)
        Me.Controls.Add(Me.cmdPrint1)
        Me.Controls.Add(Me.CrystalReportViewer1)
        Me.Name = "frmIDBarcode_Input"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.ResumeLayout(False)

    End Sub

#End Region

    'Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
    '    Dim cr As IDBarcode_Input = New IDBarcode_Input
    '    Try
    '        cr.SetDataSource(dsObj)
    '        CrystalReportViewer1.ReportSource = cr
    '    Catch ex As Exception
    '        ErrRecording("", "frmPDReturnMaterial/LoadShortageMaterial", ex.Message)
    '    End Try
    'End Sub

    Private Sub cmdPrint1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint1.Click
        Try
            dsObj.MainTable.Clear()
            UpdatePDRM()
            CrystalReportViewer1.PrintReport()
            Me.Close()
        Catch ex As Exception
            MessageBox.Show("Loi roi ban oi")
            ErrRecording("", "frmRML/cmdPrint1_Click", ex.Message)
        End Try

    End Sub
    Private Sub UpdatePDRM()
        Dim MySQLStr As String = ""
        Dim ds As DataSet
        Try
            MySQLStr = "Select * from WH_ReceiptMaterial where Marking = '3' and MarkingLabel = '0'  and AReceiptNumber = '" & GARM & "' and (PBMarking is null or PBMarking ='1')"
            ds = MySVRTVNWConnection.ExecuteProcedureSQLTVNWSVR(MySQLStr)
            If ds.Tables.Count <> 0 AndAlso ds.Tables(0).Rows.Count > 0 Then
                For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
                    MySQLStr = "UPDATE WH_ReceiptMaterial SET PBMarking ='2'where ID ='" & ds.Tables(0).Rows(i)("ID") & "'"
                    If MySVRTVNWConnection.ExecuteSQLTVNWSVR(MySQLStr) = False Then
                        MessageBox.Show("chua Cap nhat da in nhan. tam ngung di")
                        Exit Sub
                    End If
                Next
            End If
        Catch ex As Exception
            MessageBox.Show("Loi roi ban oi")
            ErrRecording("", "frmRML/UpdatePDRM", ex.Message)
        End Try
    End Sub

    Private Sub frmIDBarcode_Input_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim cr As RMLabel = New RMLabel
        Try
            SetDefaultPrinter(PrinterID, "", "")
            cr.PrintOptions.PrinterName = PrinterID
            cr.SetDataSource(dsObj)
            CrystalReportViewer1.ReportSource = cr
        Catch ex As Exception
            ErrRecording("", "frmRML/LoadShortageMaterial", ex.Message)
        End Try
    End Sub
End Class
